@extends('admin')

@section('content')

    <div class="nav">
        <ul class="cc">
            <li class="current">
                <a href="{{url('admin/categories')}}">分类管理</a>
            </li>
        </ul>
    </div>

    <p class="mb10">
        <a href="{{url('admin/categories/update')}}" class="btn J_dialog" title="新增分类"><span class="add"></span>新增分类</a>
    </p>

    <div class="table_list">
        <div id="data_list">
            <table class="items">
                <thead>
                <tr>
                    <th>分类名称</th>
                    <th>上级分类</th>
                    <th>分类图标</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach ($list as $item)
                    <tr style="font-weight:bold;">
                        <td>{{$item->name}}</td>
                        <td>顶级分类</td>
                        <td><img src="{{url('img/category-'.$item->icon.'/30-30')}}" /></td>
                        <td>{{$item->sort}}</td>
                        <td>
                            <a href="{{url('admin/categories/update/'.$item->id)}}" title="编辑 {{$item->name}}" class="mr10 J_dialog">[编辑]</a>
                            <a href="{{url('admin/categories/update/0/'.$item->id)}}" title="新增分类" class="mr10 J_dialog">[新增下级]</a>
                            @if(count($item->sub) ==  0)
                            <a href="{{url('admin/categories/delete/'.$item->id)}}" class="mr10 J_ajax_del">[删除]</a>
                            @endif
                        </td>
                    </tr>
                    @foreach($item->sub as $k => $sub)
                        <tr>
                            <td>@if($k+1 == count($item->sub)) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;└─ @else &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;├─ @endif  {{$sub->name}}</td>
                            <td>@if($sub->parent) {{$sub->parent->name}} @else 顶级分类 @endif</td>
                            <td><img src="{{url('img/category-'.$sub->icon.'/30-30')}}" /></td>
                            <td>{{$sub->sort}}</td>
                            <td>
                                <a href="{{url('admin/categories/update/'.$sub->id)}}" title="编辑 {{$sub->name}}" class="mr10 J_dialog">[编辑]</a>
                                <a href="{{url('admin/categories/delete/'.$sub->id)}}" class="mr10 J_ajax_del">[删除]</a>
                            </td>
                        </tr>
                    @endforeach
                @endforeach
                </tbody>
            </table>
        </div>

    </div>

@stop